<template>
  <div class="app-container">
    <table id="dynamic-table" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
          <th class="center" style="width: 50px;">序号</th>
          <th class="center">名称</th>
          <th class="center" width="150">计量单位（g）</th>
          <th class="center">记分比例</th>
        </tr>
        </thead>
        <tbody>
        <tr>
          <td class="center">1</td>
          <td class="center">
            厨余垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.kitchenWaste"></el-input>
          </td>
          <td class="center">
            {{ temp.kitchenWaste }} : 1
          </td>
        </tr>
        <tr>
          <td class="center">2</td>
          <td class="center">
            纸类垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.paper"></el-input>
          </td>
          <td class="center">
            {{ temp.paper }} : 1
          </td>
        </tr>

        <tr>
          <td class="center">3</td>
          <td class="center">
            金属垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.metal"></el-input>
          </td>
          <td class="center">
            {{ temp.metal }} : 1
          </td>
        </tr>

        <tr>
          <td class="center">4</td>
          <td class="center">
            塑料垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.plastic"></el-input>
          </td>
          <td class="center">
            {{ temp.plastic }} : 1
          </td>
        </tr>

        <tr>
          <td class="center">5</td>
          <td class="center">
            玻璃垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.glass"></el-input>
          </td>
          <td class="center">
            {{ temp.glass }} : 1
          </td>
        </tr>

        <tr>
          <td class="center">6</td>
          <td class="center">
            其他垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.other"></el-input>
          </td>
          <td class="center">
            {{ temp.other }} : 1
          </td>
        </tr>
        <tr>
          <td class="center">6</td>
          <td class="center">
            回收垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.recycling"></el-input>
          </td>
          <td class="center">
            {{ temp.recycling }} : 1
          </td>
        </tr>
        <tr>
          <td class="center">6</td>
          <td class="center">
            有害垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.harmful"></el-input>
          </td>
          <td class="center">
            {{ temp.harmful }} : 1
          </td>
        </tr>
        <tr>
          <td class="center">6</td>
          <td class="center">
            织物垃圾
          </td>
          <td class="center">
            <el-input type="number" v-model="temp.fabric"></el-input>
          </td>
          <td class="center">
            {{ temp.fabric }} : 1
          </td>
        </tr>
        <tr>
          <td class="center" colspan="10">
            <el-button type="primary" size="mini" @click="save">保存</el-button>
          </td>
        </tr>
        </tbody>
      </table>
  </div>
</template>

<script>
  import { getList, sureEdit } from '@/api/commodity/PointRules'

  export default {
    data() {
      return {
        list: null,
        temp: {
          plastic: '',
          glass: '',
          other: '',
          paper: '',
          fabric: '',
          metal: '',
          recycling: '',
          kitchenWaste: '',
          harmful: ''
        },
        listLoading: true
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData() {
        this.listLoading = true
        getList().then(response => {
          this.temp = response.data
          this.listLoading = false
        })
      },
      save() {
        const temData = Object.assign({}, this.temp)
        sureEdit(temData).then(response => {
          this.$notify({
            title: '成功',
            message: '提交修改成功',
            type: 'success'
          })
        })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .filter-container{
    padding-bottom: 10px;
  }
  .table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    border-radius: 0 !important;
    border: 1px solid #dddddd;
    min-height: 100%;
    padding-bottom: 0;
    font-family: 'Open Sans';
    font-size: 13px;
    color: #666;
    line-height: 1.5;
  }
  .table-striped > tbody > tr:nth-child(odd) {
    background-color: #f9f9f9;
  }
  .table > thead > tr > th, .table > tbody > tr > th, .table > tfoot > tr > th, .table > thead > tr > td, .table > tbody > tr > td, .table > tfoot > tr > td {
    padding: 8px;
    line-height: 1.42857143;
    vertical-align: top;
    border-top: 1px solid #dddddd;
  }
  .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
    border-right: 1px solid #dddddd;
  }
  select {
    padding: 3px 4px;
    height: 32px;
    margin-top: 0;
    border-radius: 0;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    color: #858585;
    background-color: #ffffff;
    border: 1px solid #d5d5d5;
  }
  select option, select.form-control option {
    padding: 3px 4px 5px;
  }
  textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"] {
    border-radius: 0 !important;
    color: #858585;
    background-color: #ffffff;
    border: 1px solid #d5d5d5;
    padding: 4px 4px 5px;
    font-size: 14px;
    font-family: inherit;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-transition-duration: 0.1s;
    transition-duration: 0.1s;
  }
  .center, .align-center {
    text-align: center !important;
  }
</style>
